package fr.afcepf.ai85.gepeto.service;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

import fr.afcepf.ai85.ent.Ecole;
import fr.afcepf.ai85.hibernate.util.HibernateUtil;

public class ServiceEcole {
	
//	public static void main(String[] args) {
//		for(String e: ListeDesEcoles()){
//		System.out.println(e);
//		}
//	}
/*static*/	public List<String> ListeDesEcoles() {
		Ecole p = null;

		Session session = HibernateUtil.currentSession();
		Transaction tx = session.beginTransaction();
		// String date = "";

		Query hql1 = session.createQuery("FROM Ecole");

		List<Ecole> listeEcoleData = hql1.list();

		List<String> listeEcoles = new ArrayList<String>();

		for (Ecole e : listeEcoleData) {

			System.out.println(e.getTypeEcole().getIdTypeEcole());
			if (e.getTypeEcole().getIdTypeEcole() == 1) {

				listeEcoles.add("Mat. " + e.getNomEcole());
			} else {

				listeEcoles.add("Prim. " + e.getNomEcole());

			}

		}

		HibernateUtil.closeSession();

		return listeEcoles;
	}

}
